package com.yida.wy.basic.controller;

import com.mybatisflex.core.paginate.Page;
import com.yida.common.core.web.domain.AjaxResult;
import com.yida.common.core.web.page.TableDataInfo;
import com.yida.wy.basic.domain.WyConfigManagerScore;
import com.yida.wy.basic.service.IWyConfigManagerScoreService;
import com.yida.wy.common.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;

/**
 * 物业经理分数配置信息 控制层。
 *
 * @author lqq
 * @since 1.0
 */
@RestController
@RequestMapping("/wyConfigManagerScore")
@Api(tags = "物业经理分数配置信息")
public class WyConfigManagerScoreController extends BaseController {

    @Autowired
    private IWyConfigManagerScoreService wyConfigManagerScoreService;

    /**
     * 添加 物业经理分数配置信息
     *
     * @param wyConfigManagerScore 物业经理分数配置信息
     * @return {@code true} 添加成功，{@code false} 添加失败
     */
    @PostMapping("/save")
    @ApiOperation(value = "添加物业经理分数配置信息", notes = "添加物业经理分数配置信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "scoreId", value = "分数ID"),
            @ApiImplicitParam(name = "scoreCode", value = "分数项编码"),
            @ApiImplicitParam(name = "scoreType", value = "分数类型：0：加；1：减"),
            @ApiImplicitParam(name = "score", value = "分数"),
            @ApiImplicitParam(name = "scoreUnit", value = "单位倍数*1、0.1、0.01..."),
            @ApiImplicitParam(name = "status", value = "0:启用;1:停用"),
            @ApiImplicitParam(name = "delFlag", value = "删除状态：0：正常；1：删除")})
    public AjaxResult save(@RequestBody WyConfigManagerScore wyConfigManagerScore) {
        return toAjax(wyConfigManagerScoreService.save(wyConfigManagerScore));
    }


    /**
     * 根据主键删除物业经理分数配置信息
     *
     * @param id 主键
     * @return {@code true} 删除成功，{@code false} 删除失败
     */
    @DeleteMapping("/remove/{id}")
    @ApiOperation(value = "根据主键删除物业经理分数配置信息", notes = "根据主键删除物业经理分数配置信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "scoreId", value = "分数ID", required = true)
    })
    public AjaxResult remove(@PathVariable Serializable id) {
        return toAjax(wyConfigManagerScoreService.removeById(id));
    }


    /**
     * 根据主键更新物业经理分数配置信息
     *
     * @param wyConfigManagerScore 物业经理分数配置信息
     * @return {@code true} 更新成功，{@code false} 更新失败
     */
    @PutMapping("/update")
    @ApiOperation(value = "根据主键更新物业经理分数配置信息", notes = "根据主键更新物业经理分数配置信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "scoreId", value = "分数ID", required = true),
            @ApiImplicitParam(name = "scoreCode", value = "分数项编码"),
            @ApiImplicitParam(name = "scoreType", value = "分数类型：0：加；1：减"),
            @ApiImplicitParam(name = "score", value = "分数"),
            @ApiImplicitParam(name = "scoreUnit", value = "单位倍数*1、0.1、0.01..."),
            @ApiImplicitParam(name = "status", value = "0:启用;1:停用"),
            @ApiImplicitParam(name = "delFlag", value = "删除状态：0：正常；1：删除")})
    public AjaxResult update(@RequestBody WyConfigManagerScore wyConfigManagerScore) {
        return toAjax(wyConfigManagerScoreService.updateById(wyConfigManagerScore));
    }


    /**
     * 查询所有物业经理分数配置信息
     *
     * @return 所有数据
     */
    @GetMapping("/list")
    @ApiOperation(value = "查询所有物业经理分数配置信息", notes = "查询所有物业经理分数配置信息")
    public AjaxResult list() {
        return AjaxResult.success(wyConfigManagerScoreService.list());
    }


    /**
     * 根据物业经理分数配置信息主键获取详细信息。
     *
     * @param id wyConfigManagerScore主键
     * @return 物业经理分数配置信息详情
     */
    @GetMapping("/getInfo/{id}")
    @ApiOperation(value = "根据物业经理分数配置信息主键获取详细信息", notes = "根据物业经理分数配置信息主键获取详细信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "scoreId", value = "分数ID", required = true)
    })
    public AjaxResult getInfo(@PathVariable Serializable id) {
        return AjaxResult.success(wyConfigManagerScoreService.getById(id));
    }


    /**
     * 分页查询物业经理分数配置信息
     *
     * @param page 分页对象
     * @return 分页对象
     */
    @GetMapping("/page")
    @ApiOperation(value = "分页查询物业经理分数配置信息", notes = "分页查询物业经理分数配置信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "pageNum", value = "页码", required = true),
            @ApiImplicitParam(name = "pageSize", value = "每页大小", required = true)
    })
    public TableDataInfo page(Page<WyConfigManagerScore> page) {
        return getDataTable(wyConfigManagerScoreService.page(page));
    }
}